| Conditions | 1 |
| Paths | 2 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | export function throttle(callback, scope, limit = 100, options = {}) { |
||
| 17 | if (options.trailing) { |
||
| 18 | callback.apply(scope, arguments); |
||
| 19 | } |
||
| 20 | if (options.leading === false) { |
||
| 21 | skip = true; |
||
| 22 | } |
||
| 23 | }, limit + limit * 0.15); |
||
| 24 | |||
| 25 | return function dothrottle() { |
||
| 26 | |||
| 27 | if (!wait && !skip) { |
||
| 28 | callback.apply(scope, arguments); |
||
| 29 | wait = true; |
||
| 30 | setTimeout(() => { |
||
| 31 | wait = false; |
||
| 32 | if (later) { |
||
| 33 | later.apply(scope, arguments); |
||
| 34 | } |
||
| 35 | }, limit); |
||
| 36 | } |
||
| 37 | else if (!wait && skip) { |
||
| 38 | wait = true; |
||
| 39 | setTimeout(() => { |
||
| 40 | skip = false; |
||
| 41 | wait = false; |
||
| 42 | if (later) { |
||
| 75 |